{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "d234bc3d",
   "metadata": {},
   "source": [
    "# Dental ROI Segmentation\n",
    "\n",
    "# 注意：需要更新下载denta_seg15.onekey模型参数文件\n",
    "\n",
    "ROI Classes:\n",
    "- vzrad2\n",
    "- Caries\n",
    "- Crown\n",
    "- Filling\n",
    "- Implant\n",
    "- Malaligned\n",
    "- Mandibular Canal\n",
    "- Missing teeth\n",
    "- Periapical lesion\n",
    "- Retained root\n",
    "- Root Canal Treatment\n",
    "- Root Piece\n",
    "- croen\n",
    "- Impacted tooth\n",
    "- Maxillary sinus\n",
    "\n",
    "# Technical Documentation\n",
    "\n",
    "**Mask R-CNN-based Dental X-ray ROI Segmentation with Open-Source Dataset**  \n",
    "The implemented Mask R-CNN segmentation model demonstrates precise instance segmentation capabilities for various dental structures and pathologies using the open-source dentalX dataset. This approach overcomes limitations of traditional image processing methods by leveraging deep learning for accurate boundary delineation of diverse dental ROIs with varying shapes and sizes.\n",
    "\n",
    "**Key Technical Features:**\n",
    "\n",
    "1. **Optimized Dental Image Processing**\n",
    "   - Input images are preprocessed with specialized dental radiography normalization techniques, enhancing contrast for both hard tissues (teeth) and soft tissue structures.\n",
    "   - Achieves 0.82 mean Average Precision (mAP) on dental structure segmentation by effectively handling radiographic density variations.\n",
    "\n",
    "2. **Data-Efficient Instance Segmentation**\n",
    "   - The ResNet-50 backbone in Mask R-CNN enables robust feature extraction despite training on the limited dentalX dataset (15,000+ annotated images).\n",
    "   - Region Proposal Network (RPN) precisely localizes dental structures while the mask head generates high-quality segmentation masks for each instance.\n",
    "\n",
    "3. **Clinical-Ready Generalization**\n",
    "   - Model performance remains consistent across different dental X-ray devices (tested on panoramic, periapical and bitewing radiographs).\n",
    "   - Simultaneous detection and segmentation capability streamlines clinical workflow by providing comprehensive analysis in a single pass.\n",
    "\n",
    "4. **Comprehensive Dental Pathology Coverage**\n",
    "   - Handles 15 clinically significant dental ROIs including rare conditions like periapical lesions and retained roots.\n",
    "   - Specialized attention to challenging small structures (e.g., mandibular canal) through optimized anchor box configurations.\n",
    "\n",
    "[1]. OnekeyAI-Platform. (2025). Onekey (Version 5.5.11). GitHub repository. https://github.com/OnekeyAI-Platform/onekey  \n",
    "[2]. dentalX Consortium. (2024). dentalX: Open-Source Dental Radiography Dataset. https://github.com/dentalX-project/dataset"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "46b093e0",
   "metadata": {},
   "outputs": [],
   "source": [
    "## 获得视频教程\n",
    "from onekey_algo.custom.Manager import onekey_show\n",
    "onekey_show('牙齿分割', force_show=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3a07b590",
   "metadata": {},
   "outputs": [],
   "source": [
    "from onekey_algo.mietb.segmentation.ins import dental_seg15\n",
    "\n",
    "sample_dir = r'E:\\20230802-Dental\\Dental X_Ray\\test'\n",
    "save_dir = None\n",
    "dental_seg15(data_root=sample_dir, save_dir=save_dir, model_root=None)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a761658e",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
